#define _CRT_SECURE_NO_WARNINGS
#include "BridgeOfLanguage.h"
#include <visualnovel/VisualNovel.h>



int main()
{
	SetConfigFlags(FLAG_WINDOW_UNDECORATED);
	InitWindow(GetScreenWidth(), GetScreenHeight(), "");
	
	SetWindowPosition(0, 0);

	bol::Rsc Rscs;

	bol::Config cfg;
	cfg.win.width = GetScreenWidth();
	cfg.win.height = GetScreenHeight();
	cfg.maxVelocity = 400.0f;
	cfg.move = true;
	cfg.fontData = rsc::SharedFile("rsc\\font\\Noto_Sans_SC\\static\\NotoSansSC-SemiBold.ttf");
	cfg.mainChrScale = 0.3f;
	cfg.textSize = 60;
	cfg.textSpeed = 1.0f;

	vn::VisualNovelConfig vnCfg;
	vnCfg.textSpeed = 1.0f;
	vnCfg.ScreenWidth = cfg.win.width;
	vnCfg.ScreenHeight = cfg.win.height;

	ecs::World2D world(cfg.win.width, cfg.win.height);
	bol::Apply(world, cfg, vnCfg);
	ui::ApplyImageBoxEx(world);
	world.addPool<bol::NavCom>();
	

	bol::SpecialId spId(world);
	rsc::SharedTexture2D mc = "rsc\\img\\MainChr.png";
	world.createUnit(spId.MainChr(), bol::MainChr{0.25f, mc, 0, 0}, bol::Velocity{0, 0}, bol::AABB{cfg.win.width * 2.0f / 3.0f, cfg.win.height / 4.0f, mc.get().width / 3.0f * cfg.mainChrScale, mc.get().height / 4.0f * cfg.mainChrScale});
	std::vector<ecs::entity> wallIds;
	for (int i = 0; i < 4; i++)
	{
		wallIds.push_back(world.getEntityManager()->getId());
	}
	world.createUnit(wallIds[0], bol::AABB{-50,-50, 50, cfg.win.height + 100.0f});
	world.createUnit(wallIds[1], bol::AABB{ -50,-50, cfg.win.width + 100.0f, 50.0f });
	world.createUnit(wallIds[2], bol::AABB{ (float)cfg.win.width, -50, 50, cfg.win.height + 100.0f });
	world.createUnit(wallIds[3], bol::AABB{ -50, (float)cfg.win.height, cfg.win.width + 100.0f, 50.0f });

	std::vector<ecs::entity> ids;
	world.addSystem(bol::EventSystem(world, spId, ids, cfg, Rscs));
	auto* eventSys = world.getSystem<bol::EventSystem>();
	world.addSystem(bol::Navigation(world, spId, ids, cfg, Rscs));
	Scene0(world, ids, spId, cfg, Rscs);
	

	while (!WindowShouldClose())
	{
		world.update();
		BeginDrawing();
		ClearBackground(BLACK);
		world.draw();
		EndDrawing();
	}
}